
public class Parabola extends OptimizedFunction {

	private double a;
	
	public Parabola(int dim, double a) {
		super(dim);
		this.a = a;
	}
	
	@Override
	public double f(double[] args) {
		double ret = 0.0;
		if (args.length != dimension)
			throw new IllegalArgumentException();
		for (double arg : args)
			ret += arg * arg;
		return a * ret;
	}

	@Override
	public double intensity(double[] args) {
		return -f(args);
	}

	@Override
	public Bound[] getBounds() {
		Bound[] ret = new Bound[dimension];
		for (int i = 0; i < dimension; i++)
			ret[i] = new Bound(-1.0 / a, 1.0 / a);
		return ret;
	}

}
